Deavmi's coding shack
Commit 6a9c9fbccd3ee8224dddabb1f55fb2dd8f956afa
Parents : 70fbb69
Author : Tristan Brice Velloza Kildaire <deavmi@redxen.eu>
Date : 2026-04-25T13:25:33+02:00
added docs
Changes
Diff
diff --git a/src/section.go b/src/section.go
index 813a23d..c863431 100644
--- a/src/section.go
+++ b/src/section.go
@@ -20,18 +20,24 @@ type Section struct {
parent *Ini
}
+// returns this section's parent
+// INI configuration
func (s Section) Parent() *Ini {
return s.parent
}
+// returns this section's name
func (s Section) Name() string {
return s.name
}
+// returns a copy of this section's
+// associated records
func (s Section) Records() []*Record {
return slices.Copy(s.records)
}
+// returns the record at the given name
func (s Section) RecordAt(name string) (*Record, error) {
for _, v := range s.records {
if v.Name() == name {
@@ -41,6 +47,8 @@ func (s Section) RecordAt(name string) (*Record, error) {
return types.Zero[*Record](), fmt.Errorf("Could not find record %s.%s", s.Name(), name)
}
+// returns the value of the record at
+// the given name parsed as an integer
func (s Section) IntAt(name string) (int, error) {
if r, e := s.RecordAt(name); e == nil {
return r.AsInt()
@@ -49,6 +57,8 @@ func (s Section) IntAt(name string) (int, error) {
}
}
+// returns the value of the record at
+// the given name parsed as a boolean
func (s Section) BoolAt(name string) (bool, error) {
if r, e := s.RecordAt(name); e == nil {
return r.AsBoolean()
@@ -57,6 +67,8 @@ func (s Section) BoolAt(name string) (bool, error) {
}
}
+// returns the string representation
+// of this section
func (s Section) String() string {
return fmt.Sprintf("%s (%v)", s.name, s.records)
}
Served by rngit 1.5.0 - Generated in 0.05s